from selenium import webdriver
wd=webdriver.Chrome(r'd:\chromedriver.exe')

wd.implicitly_wait(5)

wd.get('http://cdn1.python3.vip/files/selenium/test4.html')


wd.find_element_by_id('b2').click()

print(wd.switch_to.alert.text)
#
# wd.switch_to.alert.accept()
# wd.find_element_by_id('b2').click()

wd.switch_to.alert.dismiss()